# encoding='utf-8'
"""
@Author: 张晟烨
@Date: 2022/08/08
@Email: zhangsy@zylliondata.com
@Description:  程序接口
@Version: Python3.8
@Tester: XXX
"""
import sys
from core.deduplicate import process_data

sys.path.append('/opt/app')
from flask import Flask, request, jsonify

app = Flask(__name__)


@app.route("/deduplication", methods=['POST', 'GET'])
def deduplication():
    """
    把数据去重的函数挂在本地接口上，post请求的body中，需要添加json格式的数据（详见测试文档），返回去重之后的结果
    """
    body = request.get_json()
    dic_list = body['dictionary']
    processed_data = process_data(dic_list)
    return jsonify(processed_data)


if __name__ == '__main__':
    app.run(host='0.0.0.0', port=8000, debug=False)
